// index.js
Page({
  data: {
    flag: 0,
    currentTab: 0,
    show: false,
    //当前食物属性class
    result: [],
    // 一级导航
    menuList: [
      {
        id: "1",
        menuName: "推荐",
        children: [
          {
            id: "1001",
            childrenName: "大盘鸡",
            icon: "图标区域",
            price: "5"
          },
          {
            id: "1002",
            childrenName: "牛肉拉面",
            icon: "图标区域",
            price: "6"
          }
        ]

      },
      {
        id: "2",
        menuName: "面食",
        children: [
          {
            id: "2001",
            childrenName: "大盘鸡",
            icon: "图标区域",
            price: "5"
          },
          {
            id: "2002",
            childrenName: "牛肉拉面",
            icon: "图标区域",
            price: "6"
          }
          ,
          {
            id: "2003",
            childrenName: "炒面",
            icon: "图标区域",
            price: "6"
          }
        ]
      },
      {
        id: "3",
        menuName: "炒菜",
        children: [
          {
            id: "3001",
            childrenName: "爆炒牛肉",
            icon: "图标区域",
            price: "5"
          },
          {
            id: "3002",
            childrenName: "辣椒炒肉",
            icon: "图标区域",
            price: "6"
          }
        ]
      }
      ,
      {
        id: "4",
        menuName: "超值套餐",
        children: [
          {
            id: "4001",
            childrenName: "辣椒炒肉+雪碧",
            icon: "图标区域",
            price: "5"
          },
          {
            id: "4002",
            childrenName: "炒面+雪碧",
            icon: "图标区域",
            price: "6"
          }
        ]
      }
      ,
      {
        id: "5",
        menuName: "热点5"
      }
      ,
      {
        id: "6",
        menuName: "热点6"
      }
      ,
      {
        id: "7",
        menuName: "热点7"
      }
      ,
      {
        id: "8",
        menuName: "热点8"
      }
      ,
      {
        id: "9",
        menuName: "热点9"
      }
      ,
      {
        id: "10",
        menuName: "热点10"
      }
      ,
      {
        id: "11",
        menuName: "热点11"
      }
      ,
      {
        id: "12",
        menuName: "热点12"
      }
      ,
      {
        id: "13",
        menuName: "热点13"
      }
      ,
      {
        id: "14",
        menuName: "热点14"
      }
      ,
      {
        id: "15",
        menuName: "热点15"
      }


    ],
    activeKey: 0,
    currentMenu: [],
    showAttr: [{
      "id": 1,
      "name": "标签A",
      "price": 10.1
    }, {
      "id": 2,
      "name": "标签B",
      "price": 10.1
    }, {
      "id": 3,
      "name": "标签C",
      "price": 10.1
    }, {
      "id": 4,
      "name": "标签D",
      "price": 10.1
    }, {
      "id": 5,
      "name": "标签E",
      "price": 10.1
    }]
  },
  selectCategory: function (event) {

    // 获取当前的选择的一级菜单Id
    var id = event.target.id;
    console.info("选中的菜单id:" + id)
    var childrenList = this.data.menuList.filter(item => item.id == id);
    this.setData({
      currentMenu: childrenList[0].children
    })
  },
  catchTouchMove: function (res) {
    return false
  },
  // 弹出窗
  showCart: function () {
    this.setData({
      show: true
    })
  },
  //关闭弹出窗
  onClose: function () {
    this.setData({
      show: false
    })
  },
  // 选中食物的属性
  selectFoodAttr: function (event) {
    this.setData({
      result: event.detail,
    });
  }
})
